import java.util.ArrayList;

public class Solution405 {
    char[] chars=new char[]{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
    public String toHex(int num) {
        int flag=0;
        if (num==0){
            return "0";
        }else if (num<0){
            flag=1;
            num=-num;
        }
        ArrayList<Integer> arrayList=new ArrayList<>();
        while (num>0){
            arrayList.add(num%16);
            num=num/16;
        }
        if (flag==1){
            while (arrayList.size()<8){
                arrayList.add(0);
            }
            for (int i=0;i<8;i++){
                arrayList.set(i,15-arrayList.get(i));
            }
            int t=0;
            while (t<arrayList.size()&&arrayList.get(t)==15){
                t++;
            }
            if (t==arrayList.size()){
                return "80000000";
            }
            arrayList.set(t,arrayList.get(t)+1);
            for (int i=0;i<t;i++){
                arrayList.set(i,0);
            }
        }
        StringBuilder stringBuilder=new StringBuilder();
        for (int i=arrayList.size()-1;i>=0;i--){
            stringBuilder.append(chars[arrayList.get(i)]);
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        System.out.println(new Solution405().toHex(-1));
    }
}
